

window.onload = function () {

    //1,获取用户名
    var username = document.getElementById("username");
    //显示删除图标
    var deleteicon = document.getElementById("delete");

    //2,绑定事件
    username.oninput = function () {

        if(this.value.length>0){
            deleteicon.style.display = "block";
        }else {
            deleteicon.style.display = "none";
        }
    }


    //绑定删除图标事件
    deleteicon.onclick = function () {
        username.value = "";
    }

}